# This code is hosted on http://code.google.com/p/lenthorp/
# Freely available for use in applications, but should NOT be modified
# Email all comments to lenthorpresearch@gmail.com

from PricingEngine_AsianBlackScholesMonteCarloMod import *
from CalibratorMod import *

def runTest():
    mp = ModelParameters()
    mp.p['nsims'] = 1000000
    mp.p['randomType'] = 'mersenneinversenormal'
    mp.p['isGPU'] = True
    bsme = AsianBlackScholesMonteCarlo(mp)
    op = OptimiseParameters()
    op.p['vol'] = 0.2
    pp = PricingParameters(['strike', 'tenor', 'rate', 'initial', 'div', 'type', 'currentAverage', 'numPastFixings', 'fixingTimes'])
    pp.addPricingSet([40.0, 1.0, 0.1, 36.0, 0.0, 'put', 0.0, 0, [float(idx+1)/12.0 for idx in range(12)]],0)
    bsme.setUpParameters(pp,op)

    res = []
    bsme.preComputations()
    res.append(bsme.getPrice())
    return res
    
if __name__ == "__main__":
    res = runTest()
    print(res)